home *** CD-ROM | disk | FTP | other *** search
- ;This script creates a plane and deforms it
- ;init
-
- ;parameters
- .buffer=2
- .buffer2=3
- .width=240
- .xmin:=-60
- .xmax:=40
- .ymin:=-70
- .ymax:=30
- .z:=0
- .xsect:=8
- .ysect:=8
-
-
- ;create the plane
- .xstep=(xmax-xmin)/(xsect-1)
- .ystep=(ymax-ymin)/(ysect-1)
-
- for(i,0,xsect-2)
- .x1=xmin+i*xstep
- .x2=x1+xstep
- for(j,0,ysect-2)
- .y1=ymin+j*ystep
- .y2=y1+ystep
- addface(buffer,x1,y1,z,x2,y1,z,x2,y2,z)
- addface(buffer,x1,y1,z,x1,y2,z,x2,y2,z)
- end
- end
-
- ;merge the points and edges
- merge(buffer)
-
- ;show the generated object
- set(rotx,138)
- set(rotz,330)
- set(zoom,1.2)
- window(buffer)
-
- copy(buffer,buffer2)
-
- ;calculate the center
- pcount(buffer2)
- .cx=0
- .cy=0
- .cz=0
- for(i,0,pcount-1)
- getpoint(buffer2,i)
- .cx=cx+px
- .cy=cy+py
- .cz=cz+pz
- end
- .cx=cx/pcount
- .cy=cy/pcount
- .cz=cz/pcount
- ;show the result
- echo(----> centerX=,cx)
- echo(----> centerY=,cy)
- echo(----> centerZ=,cz)
-
- ;deform it
- for(i,0,pcount-1)
- getpoint(buffer2,i)
- .dx=px-cx
- .dy=py-cy
- .dz=pz-cz
- .pz=cz+(dx*dx+dy*dy+dz*dz)*0.01+(rnd(10)+1)*0.5
- setpoint(buffer2,i,px,py,pz)
- end
-
- ;show it
- window(buffer2)
- windowpos(2,width+10,11)
- for(i,1,10)
- windowrotx(2,-12)
- windowrotz(2,6)
- end
-
- ;exit
- request("Exit",Yes,Yes)
-